<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 100px;
      height: 100px;
      background: #000;
      border: 10px solid #eed80b;
    }

    body {
      padding-left: 10px;
    }

    div {
      display: inline-block;
    }
  </style>
</head>

<body>
  <div class="text">hello</div>
  <div class="box"></div>

  <script>
    let box = document.querySelector('.box')

    box.addEventListener('click', function () {
      box.style.width = 200 + 'px';
      console.log(box.offsetWidth)

      box.style.width = 300 + 'px';
      console.log(box.offsetWidth)

      box.style.width = 400 + 'px';
      console.log(box.offsetWidth)

      box.style.width = 50 + 'px';
      console.log(box.offsetWidth)
    })
  </script>
</body>

</html>